package games.checkers;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;

public class boardTile extends Rectangle
{
	private checkersBoard board;
	private int tile;
	private Color color;
	private Color brighter;
	private Color evenBrighter;
	private boolean highlight;
	private int [] forward;
	private int [] backward;
	
	public boardTile(int t,Point p, Dimension d,Color c, int [] f, int [] b, checkersBoard cb)
	{
		super(p.x,p.y,d.width,d.height);
		board = cb;
		tile = t;
		//Point p = board.getTilePosition(tile);
//		width = d.width;
//		height = d.height;
//		x = p.x-width/2;
//		y = p.y-height/2;
		
		setColor(c);
		
		forward = f;
		backward = b;

	}
	
	public void setColor(Color c)
	{
		color = c;
		int r = c.getRed();
		int g = c.getGreen();
		int b = c.getBlue();
		int rb = r+75;
		int gb = g+75;
		int bb = b+75;
		if (rb > 255) rb = 255;
		if (gb > 255) gb = 255;
		if (bb > 255) bb = 255;
		brighter = new Color(rb,gb,bb);
		int reb = rb+75;
		int geb = gb+75;
		int beb = bb+75;
		if (reb > 255) reb = 255;
		if (geb > 255) geb = 255;
		if (beb > 255) beb = 255;
		evenBrighter = new Color(reb,geb,beb);
	}
	
	public void highlight(boolean val)
	{
		highlight = val;
	}
	
	public int [] backward()
	{
		return backward;
	}
	
	public int [] forward()
	{
		return forward;
	}
	
	public void paint(Graphics g)
	{
		Graphics2D g2d = (Graphics2D) g;
		Color oldColor = g2d.getColor();
		
		if (highlight)
		{
			g2d.setColor(brighter); 
			g2d.fill(this);
			g2d.setStroke(new BasicStroke(3));
			g2d.setColor(evenBrighter); 
			g2d.draw(this);
		}
		else 
		{
			g2d.setColor(color);
			g2d.fill(this);
		}
		
		g2d.setColor(oldColor);
	}

}
